home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
dirut
/
nfd104.zip
/
NFD.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-11-25
|
30KB
|
667 lines
TITLE NFD - New File Date Utility 1.03 28 Oct 87
page 62,132
;*************************************************************************
; This program is NOT copyrighted in any way and may be used in whole or
; in part in any manner. The author, as is usual, makes no claims about
; the suitability of this program for any purpose whatsoever and disclaims
; liability for any damages, actual or consequential, that may arise from
; use of this program.
;
; Don A. Williams
; 7 Mar 86
;*************************************************************************
;*************************************************************************
; The source for NFD, NFD.ASM, as issued is intended for use with
; SpeedWare's excellent assembler, Turbo Editasm. For use with Micrsoft's
; MASM, SEGMENT, ASSUME, and ENDS statements will have to be added.
;*************************************************************************
;*************************************************************************
; Source modified on 28 Oct 87 for use with MASM and added a conditional
; to GetArgs in order to allow the "Usage: . . ." output when no arguments
; are supplied. (Aside: the differences in the generated machine code,
; MASM vs. Turbo Editasm, are interesting to say the least. CISC cause
; no doubt.) -- Will Jordan
; Source modified again 25 Nov 87 -- flipped condition (jnz, was jz) 2
; lines before "GotDir:"; corrected "Could not find file" message when
; the filename is explicitly entered.
;*************************************************************************
CODESEG segment para public 'code'
assume cs:CODESEG,ds:CODESEG,es:CODESEG,ss:CODESEG
LF EQU 0AH
CR EQU 0DH
DTA EQU 80H ; define (default) DTA of PSP
FATTRD EQU byte ptr DTA[21] ; defining all parm's, even not used
FTIMED EQU word ptr DTA[22]
FDATED EQU word ptr DTA[24]
FSIZLD EQU word ptr DTA[26]
FSIZHD EQU word ptr DTA[28]
FNAMED EQU byte ptr DTA[30]
ARDONLY EQU 01H ; define file attribute (FATTR) bits
AHIDDEN EQU 02H
ASYSTEM EQU 04H
AVOLLAB EQU 08H
ASUBDIR EQU 10H
AARCHIV EQU 20H
ORG 0100H
Start: jmp Begin
DateSw dw 0
TimeSw dw 0
NFDate dw 0 ; New Date for file
NFTime dw 0 ; New Time for file
FDate dw 0 ; File Date From/To Function 57H
FTime dw 0 ; File Time From/To Function 57H
Hour dw 0
Minute dw 0
Second dw 0
Day dw 0
Month dw 0
Year dw 0
ArgSep db 0
TmpCnt dw 0
PtrOfs dw 0
UseMsg db 'Usage is: NFD <filename> [mm/dd/yy] [hh:mm:ss]',CR,LF
db ' /s for silent operation (no STDOUT)',CR,LF
db ' /n for no query',CR,LF,'$'
NFMsg db 'Could not find file',CR,LF,'$'
BDMsg db 'Incorrect date',2CH,' format is mm/dd/yy or mm-dd-yy',CR,LF,'$'
BTMsg db 'Incorrect time',2CH,' format is hh:mm:ss',CR,LF,'$'
IntMsg db 'Internal error during file access',CR,LF,'$'
SignOn db 'NFD Version: 1.04 - 25 Nov 87',CR,LF,LF,0
From db CR,LF,' From: ',0
To db ' To: ',0
CrLfMs db CR,LF,0
Query db ' Change? ',0
Begin: mov SI,offset SignOn ; Display logon message
call PrtStr ; ...
call GetArgs ; Parse Command Line arguments
cmp word ptr ARGC,0 ; Check for no arguments
jz Usage ; ... Xfr - no arguments
cmp word ptr ARGC,4 ; Check for more than 4 arguments
ja Usage ; ... Xfr - more than 4
call GetPath ; Extract Path from File Path Name
call DateTime
cmp word ptr DateSw,0 ; Check for Date argument
jne CheckTime ; ... Xfr - Date on Command Line
mov AH,2AH ; MS-DOS 'Get Date'
int 21H ; ... DOS Entry Interrupt
sub CX,1900 ; Make Year 1900 relative
mov Year,CX ; ... and save it
mov CL,DH ; Move Month to CX as 16-bit value
mov CH,0 ; ...
mov Month,CX ; ... and save it
mov CL,DL ; Move Day to CX as 16-bit value
mov Day,CX ; ... and save it
CheckTime:
cmp word ptr TimeSw,0 ; Check for Time on Command Line
jne Here ; ... Xfr - Time on Command Line
mov AH,2CH ; MS-DOS 'Get Time'
int 21H ; ... DOS Entry Interrupt
mov AX,0 ; Move Hour to AX as 16-bit value
mov AL,CH ; ...
mov Hour,AX ; ... and save it
mov AL,CL ; Move Minute to AX as 16-bit value
mov Minute,AX ; ... and save it
mov AL,DH ; Move Second to AX as 16-bit value
mov Second,AX ; ... and save it
mov word ptr DateSw,0FFH
mov word ptr TimeSw,0FFH
Here: jmp Format
Usage: mov DX,offset UseMsg ; Display 'Usage' message
mov AH,9 ; ... MS-DOS 'Print String'
int 21H ; ... DOS Entry Interrupt
mov AL,1 ; Set error code
jmp Term ; ... and terminate
DateTime:
mov AX,ARGC ; Initialize loop counter to ARGC
mov TmpCnt,AX ; ...
mov word ptr PtrOfs,0 ; Initialize Arg ptr offset to 0
ArgLoop:
add word ptr PtrOfs,2 ; Incr Arg ptr offset
dec word ptr TmpCnt ; ... and decr loop count
jnz DoArg ; ... Xfr - loop count not exhausted
ret
DoArg:
mov BX,PtrOfs ; Get Arg ptr offset
mov SI,[BX+ARGV] ; ... and Arg ptr
mov AL,byte ptr [SI] ; Check for switch arg
cmp AL,'/' ; ... primary switch char
je Switch ; ... Xfr - got switch
cmp AL,'-' ; ... secondary switch char
je Switch ; ... Xfr - got switch
call GetNumber ; Convert 1st arg field to binary
cmp AL,'/' ; Check for Date field separator
jz GotMonth ; ... Xfr - got separator
cmp AL,'-' ; Check for Date field separator
jz GotMonth ; ... Xfr - got separator
cmp AL,':' ; Check for Time field spearator
jnz Usage ; ... Xfr - bad format
jmp GotHour ; Xfr - got separator
Switch:
inc SI ; Skip switch char
SWLoop: lodsb ; Get byte
cmp AL,0 ; Check for NULL terminator
je ESW ; ... Xfr - NULL - end of Arg
and AL,0DFH ; Force upper case
cmp AL,'N' ; Check for 'No Query'
je NQ ; ... Xfr - 'No Query
cmp AL,'S' ; Check for 'Silent'
je Silent ; ... Xfr - 'Silent'
jmp Usage ; Xfr - invalid switch
NQ: mov byte ptr QSwt,0FFH ; Turn on No Query Switch
jmp short SWLoop ; Go try for another switch
Silent: mov byte ptr SSwt,0FFH ; Turn on Silent Switch
jmp short SWLoop ; Go try for another switch
ESW: jmp ArgLoop ; Go try for another argument
ErExit: mov AH,9 ; MS-DOS 'Print String'
int 21H ; ... DOS Entry Interrupt
mov AL,2